<?php
/**
 * Created by PhpStorm.
 * User: 颖inv
 * Date: 2016/10/14
 * Time: 13:01
 */
header('Content-type:text/html; charset=utf-8');
?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>订货单显示</title>
    <style>
        body{background-color: #eeeeee; font-size: 14px;}
        table{*border-collapse:collapse; border-spacing:0; color:#2B2B2B;}
        .bordered{border:solid #DADADA; 1px; background-color: #fff; text-align: center;}
        .bordered tr,td{border: solid #DADADA 1px;padding:10px;}
        .bordered tr:nth-child(5){text-align: right;}
        .bordered tr:nth-child(1){font-weight: bold;}
        h2{margin-left: 160px;}
    </style>
</head>
<body>
<?php
$goods=array(
    array('name'=>'主板','price'=>'379','producing'=>'广东','num'=>3),
    array('name'=>'显卡','price'=>'799','producing'=>'上海','num'=>2),
    array('name'=>'硬盘','price'=>'589','producing'=>'北京','num'=>5)
);
    $total=0;
    $str="<table class='bordered'>";
    $str.="<tr><td>商品名称</td><td>价格（元）</td><td>产地</td>";
    $str.="<td>数量（件）</td><td>总价（元）</td></tr>";
    foreach ($goods as $values){
        $str.='<tr>';
        foreach ($values as $v){
            $str.='<td>'.$v.'</td>';
        }
        $sum=$values['price'] * $values['num'];
        $str.='<td>'.$sum.'</td>';
        $str.='</tr>';
        $total +=$sum;
    }
$str.="<tr><td colspan='5'>小计：".$total."元</td></tr></table>";
echo "<h2>商品订货单</h2>";
echo $str;
?>
</body>
</html>
